/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights
 * reserved. <a>http://www.cqcis.com</a>
 */
package com.cqcis.uip.base.framework.adaptor;

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;

/**
 * 命名参数模板
 * 
 * @author huangmy
 * @date   2008-7-29
 */
public class SimpleJdbcTemplateAdaptor extends SimpleJdbcTemplate {
	private NamedParameterJdbcOperations namedParameterJdbcOperations;

	public SimpleJdbcTemplateAdaptor(DataSource dataSource) {
		super(dataSource);
		this.namedParameterJdbcOperations = new NamedParameterJdbcTemplateAdaptor(dataSource);
	}
	
	public SimpleJdbcTemplateAdaptor(JdbcOperations classicJdbcTemplate) {
		super(classicJdbcTemplate);
		this.namedParameterJdbcOperations = new NamedParameterJdbcTemplateAdaptor(classicJdbcTemplate);
	}
	
	public SimpleJdbcTemplateAdaptor(NamedParameterJdbcOperations namedParameterJdbcTemplate) {
		super(namedParameterJdbcTemplate);
		this.namedParameterJdbcOperations = namedParameterJdbcTemplate;
	}
	
	public SimpleJdbcTemplateAdaptor(SimpleJdbcTemplate sjt) {
		this(sjt.getJdbcOperations());
		this.namedParameterJdbcOperations = new NamedParameterJdbcTemplateAdaptor(sjt.getJdbcOperations());
	}
	
	/**
	 * Expose the classic Spring JdbcTemplate to allow invocation of
	 * less commonly used methods.
	 */
	public JdbcOperations getJdbcOperations() {
		return this.namedParameterJdbcOperations.getJdbcOperations();
	}

	/**
	 * Expose the Spring NamedParameterJdbcTemplate to allow invocation of
	 * less commonly used methods.
	 */
	public NamedParameterJdbcOperations getNamedParameterJdbcOperations() {		
		return this.namedParameterJdbcOperations;
	}
}
